var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
function  increaseId(){
    MongoClient.connect(url,{useNewUrlParser:true},async function(err,db){
        if(err) throw err;
        var dbo = db.db("mongo");
        var count = dbo.collection('ids').countDocuments();
        if(!count){
            dbo.collection('ids').insert({
                name:'user',
                id:0
            })
        }
        let id = await dbo.collection('ids').findOneAndUpdate({"name":"user"},{$inc:{'id':1}},{returnNewDocument:true})
        console.log(id)
    })
}
increaseId()